#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
@Author: kindey
@Date: 2025/8/7
@Description: 
"""
from apps.repositories.data_repository import DataRepository
from apps.repositories.dic_small_class_repository import DictSmallClassRepository

class DataService:
    def __init__(self):
        self.data_repository = DataRepository()
        self.dict_repository = DictSmallClassRepository()

    def get_all_data(self):
        return self.data_repository.get_all_data()

    def get_data_by_id(self, data_id):
        return self.data_repository.get_data_by_id(data_id)

    def get_data_by_device(self, device_id):
        return self.data_repository.get_data_by_device_id(device_id)

    def get_device_data_with_details(self, device_id):
        """
        获取设备数据详情，包含设备相关信息
        对应SQL: select a.data_time,max(a.data_value1,a.data_value2) dataValue...
        """
        return self.data_repository.get_device_data_with_joins(device_id)

    def create_data(self, data_dict):
        return self.data_repository.create_data(data_dict)

    def update_data(self, data_id, data_dict):
        return self.data_repository.update_data(data_id, data_dict)

    def delete_data(self, data_id):
        return self.data_repository.delete_data(data_id)

class DictSmallClassService:
    def __init__(self):
        self.dict_repository = DictSmallClassRepository()

    def get_device_info(self, device_id):
        return self.dict_repository.get_device_info(device_id)

    def get_devices_with_region_info(self):
        """
        获取设备区域信息统计
        """
        return self.dict_repository.get_devices_with_region_info()